<?php if (!defined('THINK_PATH')) exit();?><style>
	/*随车发运打印预览页面css*/
.printLsh{
	padding:15px 5px 15px 5px;

}
.head1 span{
	font-size: 24px;
    font-weight: bold;
}
.head1 img{
	width:50px;
}

.fyTb {
    border: 1px solid #000;
    border-collapse: collapse;
    width:100%;
}
.fyTb td,.fyTb th {
    border: 1px solid #000;
    padding:2px;
  }
.hrLine{
     vertical-align: middle;
    display: inline-block;
    border: none;
    border-top: 1px dashed #E7E9EA;
    padding-top: 5px;
}
/*裁剪样式*/
 .personal-mybuluo-head {
        height: 14px;
        position: relative;
        margin-top: 30px;
    }
    
    .personal-mybuluo-wording {
        position: absolute;
        top: 0;
        z-index: 2;
        left: 50%;
        background-color: #fff;
        color: #777;
        text-align: center;
        -webkit-transform: translate(-50%, 0);
        transform: translate(-50%, 0);
        padding: 0 10px;
    }
   
    
    .personal-border {
        position: absolute;
        top: -7px;
        left: 0;
        width: 100%;
        height: 14px;
        z-index: 1;
    }
    
    .jmu-border-1px {
        position: relative;
    }
    
    .jmu-border-1px.border-bottom:after {
        border-bottom: 1px dashed #dedfe0;
    }
    
    @media only screen and (-webkit-min-device-pixel-ratio: 2) .jmu-border-1px:after {
        right: -100%;
        bottom: -100%;
        -webkit-transform: scale(0.5);
    }
    
    .jmu-border-1px:after {
        display: block;
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        -webkit-transform-origin: 0 0;
        -webkit-transform: scale(1);
        pointer-events: none;
    }
</style>
<!-- 载入打印css文件 -->
<!-- <link rel="stylesheet" type="text/css" media="print" href="/solve/Public/css/myJqPrint.css" /> -->
<link rel="stylesheet" type="text/css" media="print2" href="/solve/Public/css/myJqPrint2.css" />
<!-- 一个input，用于记载计生号 -->
<input type="hidden" id="sjjhh" value="<?php echo ($sjjhh); ?>">
<input type="hidden" id="lshqj" value="<?php echo ($lshqj); ?>">
<input type="hidden" id="rwh" value="<?php echo ($rwh); ?>">
<input type="hidden" id="isJun" value="<?php echo ($isJun); ?>">
<input type="hidden" id="tf" value="<?php echo ($tf); ?>">
<div id="print_scfy_layout" class="easyui-layout" data-options="fit:true">   

    <div data-options="region:'west',title:'流水号',split:true,border:false" style="width:200px;">
    	<table id='scfyLsh'></table>
    </div>   
    <div data-options="region:'center',title:'打印预览',border:false" style="padding:5px;background:#feee;">
    	<!-- 工具栏 -->
    	<div id="printTool" class='datagrid-toolbar'>
    		<!-- <a href="#"  onclick='print_scfy()' class="easyui-linkbutton" data-options="iconCls:'icon-standard-printer'">省纸打印</a>  -->
    		<a href="#"  onclick='print_scfy2()' class="easyui-linkbutton" data-options="iconCls:'icon-standard-printer'">打印</a> 
    		<a href="#" onclick='goBackScfyMes()' class="easyui-linkbutton" data-options="iconCls:'icon-back'">返回</a> 
    	</div>
    	<!-- 打印预览区域 -->
    	<div id="lshPrintAra"></div>
    	
    </div>   
</div> 			
			
<script>
$(function(){
var sjjhh=$('#sjjhh').val();
var lshqj=$('#lshqj').val();
var isJun=$('#isJun').val();

var lshArr=new Array();
   $.post("/solve/index.php/Home/Scfy/pipeilsh",{sjjhh:sjjhh,lshqj:lshqj,isJun:isJun},function(result){
	                 if(result.status=='1'){

	      $('#scfyLsh').datagrid({     
		    fit : true,
			width : function() {
				return document.body.clientWidth * 0.9
			},
			fitColumns:true,
			toolbar:'#scfyLsh_tool',
			striped:true,
			rownumbers:true,//显示行号
		    data:result.data,  
		    columns:[[    
		        {field:'id',checkbox:true},    
		        {field:'lsh',title:'流水号',width:100}  
		    ]],
		    pagination:true,
		    pageNumber:1,
		    pageSize:100,
		    pageList:[100,200,300],
		    border:false,
		    onSelect:function(index,row){

		        	addLshDiv(row.lsh);
		        
		        	
		    },
		    onUnselect:function(index,row){
		    	delLshDiv(row.lsh);
		    },
		     onSelectAll:function(rows){
		    	// console.log(rows);
		    	for (var i = 0; i < rows.length; i++) {
		    		addLshDiv(rows[i].lsh);
		    	}
		    },
		     onUnselectAll:function(rows){
	    	    $.messager.confirm('确认','您确认想要取消当前所有流水号的随车发运清单吗？',function(r){    
		            if (r){    
		                $("#lshPrintAra").html(""); 
		            }    
    			}); 
		    }
		});
$('#scfyLsh').datagrid('selectAll'); 

	      

for (var i = 0; i < result.data.length; i++) {
	lshArr[i]=result.data[i].lsh;
}

	                 }else{
	                    $.messager.alert('数据', result.data, 'info');
	                 }

	            },"json");


   	// 生成计生号数据
// 	   $.post("/solve/index.php/Home/Scfy/pipei",{sjjhh:sjjhh},function(result){
// 	                 if(result.status=='1'){
// 	                 	// 清空
	   
// 	                 	$('#lshPrintAra').html("");
// 		          		for (var i = 0; i < lshArr.length; i++) {


			

// var string='<div id="print_'+lshArr[i]+'" class="printLsh">'+
// '	<div class="head1">'+
// '		<img src="/solve/Public/images/sqlogo.jpg"></img>	'+
// '		<span>陕汽控股</span>'	+
// '	</div>'+
// '	<div><h2 style="text-align:center;">随车发运附件清单</h2></div>'+
// '	<div class="head2" style="display:inline;">'+
// '		<div style="float:left;width:200px;">流水号：'+lshArr[i]+'</div>'+
// '		<div style="float:right;width:200px;">打印日期：'+nowData()+'</div>'+
// '	</div>'+
// '	<table class="fyTb">'+
// '		<tr>'+
// '			<th style="width:15%;text-align:center;">放置环节</th>'+
// '			<th style="width:30%;">零件号</th>'+
// '			<th style="width:45%;">零件名称</th>'+
// '			<th style="width:10%;text-align:center;">数量</th>'+
// '		</tr>';


// for (var q = 0; q < result.data.length; q++) {
// 	var str='		<tr>'+
// '			<td style="text-align:center;">'+result.data[q].dw+'</td>'+
// '			<td>'+result.data[q].ljh+'</td>'+
// '			<td>'+result.data[q].mc+'</td>'+
// '			<td style="text-align:center;">'+result.data[q].sl+'</td>'+
// '		</tr>';
// string=string+str;
// }

// string=string+
// '	</table>'+
// '</div>'+
// '<hr>';
// 							$('#lshPrintAra').append(string);


// 						}
// 	                 }else{
// 	                    $.messager.alert('数据', result.data, 'info');
// 	                 }

// 	            },"json");

	
	
	})
/**
 * [nowData 当前日期]
 * @return {[type]} [description]
 */
  function nowData(){
    var mydate = new Date();
    var str = "" + mydate.getFullYear() + "年";
    str += (mydate.getMonth()+1) + "月";
    str += mydate.getDate() + "日";
    return str;
   }
 /**
  * [delLshDiv 删除流水号div]
  * @param  {[type]} lsh [description]
  * @return {[type]}     [description]
  */
function delLshDiv(lsh){
var div=$("#print_"+lsh);
var b=$("#break-"+lsh);
if(div.length>0){
	div.remove();
	b.remove();
}else{

}
}
/**
 * [addLshDiv 添加流水号div]
 * @param {[type]} lsh [description]
 */
function addLshDiv(lsh){
var div=$("#print_"+lsh);
var sjjhh=$('#sjjhh').val();
var rwh=$('#rwh').val();
var tf=$('#tf').val();
if(div.length>0){
		  	$.messager.alert('数据', '已经存在', 'info');
	}else{
		
	if(tf!=""){
		lsh=tf;
	}
		 $.post("/solve/index.php/Home/Scfy/pipei",{sjjhh:sjjhh,tf:tf},function(result){
	                 if(result.status=='1'){
							var string='<div id="print_'+lsh+'" class="printLsh">'+
							'	<div class="head1">'+
							'		<img src="/solve/Public/images/sqlogo.jpg"></img>	'+
							'		<span>陕汽控股</span>'	+
							'	</div>'+
							'	<div><h2 style="text-align:center;">随车发运附件清单</h2></div>'+
							'	<div class="head2" style="display:inline;">'+
							'		<div style="float:left;width:200px;">流水号：'+lsh+'</div>'+
							'		<div style="float:right;width:200px;">打印日期：'+nowData()+'</div>'+
							'	</div>'+
							'	<table class="fyTb">'+
							'		<tr>'+
							'			<th style="width:15%;text-align:center;">放置环节</th>'+
							'			<th style="width:30%;">零件号</th>'+
							'			<th style="width:45%;">零件名称</th>'+
							'			<th style="width:10%;text-align:center;">数量</th>'+
							'		</tr>';



							for (var q = 0; q < result.data.length; q++) {
								var str='		<tr>'+
							'			<td style="text-align:center;">'+result.data[q].dw+'</td>'+
							'			<td>'+result.data[q].ljh+'</td>'+
							'			<td>'+result.data[q].mc+'</td>'+
							'			<td style="text-align:center;">'+result.data[q].sl+'</td>'+
							'		</tr>';
							string=string+str;
							}

							string=string+
							'	</table>'+
							'	<div class="head2" style="display:inline;">'+
							'		<div style="float:left;width:200px;">计生号：'+sjjhh+'</div>'+
							'		<div style="float:right;width:200px;">任务号：'+rwh+'</div>'+
							'</div><div id="break-'+lsh+'" style="page-break-after:always"></div>';

							$('#lshPrintAra').append(string);
					
	                 }else{
	                    $.messager.alert('数据', result.data, 'info');
	                 }

	            },"json");	
}

	

}

/**
 * [print_scfy 显示打印预览]
 * @return {[type]} [description]
 */
function print_scfy(){

	$('#lshPrintAra').jqprint(
		media="print"
		);

}
function print_scfy2(){
	//将最后一个分割去掉
	$("#lshPrintAra").children("div:last-child").children("div:last-child").remove();

	$('#lshPrintAra').jqprint(
		media="print2"
		);

}
/**
 * [goBackScfyMes 返回随车发运数据清单]
 * @return {[type]} [description]
 */
function goBackScfyMes(){
   var tab = $('#tab').tabs('getSelected'); 

    // tab.panel('refresh', '/solve/index.php/Home/Scfy/show');
    tab.panel('refresh', '/solve/index.php/Home/Scfy/index');
}


</script>